package com.dkh.recommend.controller;


import com.dkh.recommend.dto.Result;
import com.dkh.recommend.entity.TbBlogComment;
import com.dkh.recommend.entity.TbComment;
import com.dkh.recommend.service.ITbCommentService;
import com.dkh.recommend.service.TbBlogCommentService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dkh
 * @since 2022-12-14
 */
@Slf4j
@RestController
@Api(value = "评论", tags = "评论-相关", description="评论-相关")
@RequestMapping("/blogcomment")
public class TbBlogCommentController {

    @Autowired
    private TbBlogCommentService blogCommentService;

//    评论2音乐故事
    @PostMapping("/add")
    public Result addComment(@RequestBody TbBlogComment comment){
        return blogCommentService.addComment(comment);
    }

//    查看我的评论
    @GetMapping("/myComment")
    public Result myBlogComment(){
        return blogCommentService.myBlogComment();
    }

//    删除评论
    @DeleteMapping("/delete/{blogCommentId}")
    public Result deleteComment(@PathVariable("commentId") String commentId){
    return blogCommentService.deleteComment(commentId);
    }

//    根据音乐故事id获得音乐的评论
    @GetMapping("/byblogid/{blogId}")
    public Result getCommentByBlogId(@PathVariable("blogId") String blogId){
        return blogCommentService.getCommentByBlogId(blogId);
    }

//    点赞/取消点赞
    @PutMapping("/like/{commentId}")
    public Result likeComment(@PathVariable("commentId") String commentId){
        return blogCommentService.likeComment(commentId);
    }

//   是否点赞
    @GetMapping("/or/not/like/{commentId}")
    public Result orNotLike(@PathVariable("commentId") String commentId){
        return blogCommentService.orNotLike(commentId);
    }





}
